<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>开心E城</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> -->
        <link rel="stylesheet" href="/static/admin/css/font.css">
        <link rel="stylesheet" href="/static/admin/css/xadmin.css">
        <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
        <link rel="stylesheet" href="/static/admin/lib/bootstrap/bootstrap.min.css">   
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
        <style>
        	.layui-form-label {
        		width: 100px;
        	}
        </style>
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
					<div class="layui-form-item">
					    <label class="layui-form-label">
					    	<span class="x-red">*</span>名称
						</label>
					    <div class="layui-input-block">
					    	<div class="layui-input-inline">
					      		<input type="text" name="name" lay-verify="required" placeholder="输入名称" autocomplete="off" class="layui-input" value="{$data.name|default=''}">
					    	</div>
						</div>
				  	</div>
				  	<div class="layui-form-item">
					    <label class="layui-form-label">
					    	<span class="x-red">*</span>高度	
						</label>
					    <div class="layui-input-block">
					    	<div class="layui-input-inline">
					      		<input type="number" name="height" lay-verify="required" placeholder="输入高度" autocomplete="off" class="layui-input" value="{$data.height|default=''}" required="required">
					    	</div>
						</div>
				  	</div>
				  		<div class="layui-form-item">
					    <label class="layui-form-label">
					    	<span class="x-red">*</span>宽度	
						</label>
					    <div class="layui-input-block">
					    	<div class="layui-input-inline">
					      		<input type="number" name="width" lay-verify="required" placeholder="输入宽度" autocomplete="off" class="layui-input" value="{$data.width|default=''}" required="required">
					    	</div>
						</div>
				  	</div>
				  	<div class="layui-form-item">
					    <label class="layui-form-label">
					    	<span class="x-red"></span>描述	
						</label>
					    <div class="layui-input-block">
					      	<textarea placeholder="请输入描述" class="layui-textarea" name="desc">{$data.desc|default=''}</textarea>
						</div>
				  	</div>
					<div class="layui-form-item">
						{if isset($data.id)}
						<input type="hidden" name="id" value="{$data.id}">
						{/if}
						<label for="" class="layui-form-label"></label>
						<button type="button" class="layui-btn layui-btn-danger" lay-filter="save" lay-submit="save">保存</button>
					</div>
              </form>
            </div>
        </div>
        <script>
        	layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form;
                var layer = layui.layer;

                //自定义验证规则
                form.verify({
                    
                });

                //监听提交
                form.on('submit(save)',function(data) {
                    $.ajax({
                    	url:'{:url("backstage/ad/postitonForm")}',
                    	type:'post',
                    	dataType:'json',
                    	data:data.field,
                    	success: res => {
                    		if (res.code == 1) {
                    			layer.alert(res.msg, {
			                        icon: 6
			                    },
			                    function() {
			                        //关闭当前frame
			                        xadmin.close();
			                        // 可以对父窗口进行刷新 
			                        xadmin.father_reload();
			                    });
                    		} else {
                    			layer.alert(res.msg, {
			                        icon: 5
			                    });
                    		}
                    	},
                    	error: e => {}
                    });
                    return false;
                });

            });
        </script>
    </body>
</html>
